dojo.provide("lorelei.users");
// Lorelei user view page script
// Copyright (c)2008 Logue <http://logue.be/> All rights reserved.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

lorelei.users = {
	meta: {
		"@prefix": "<http://purl.org/net/ns/doas#>",
		"@about": "<http://mabinogi.logue.be/js/lolerei/articles.js>", a: ":JavaScript",
		 title: "Lorelei User page script",
		 created: "2008-10-13", release: {revision: "1.0", created: "2008-10-13"},
		 author: {name: "Logue", homepage: "<http://logue.be/>"},
		 license: "<http://www.gnu.org/licenses/gpl-3.0.html>"
	},
	login: function(){
		dojo.require("dojo.cookie");
		dojo.addOnLoad(function (){
			dojo.connect(dojo.byId('cancel'),'onclick',function(elem){
				this.disabled = true;
				location.href = '/';
				this.disabled = false;
			});

			dojo.connect(dojo.byId('UserLoginForm'), 'onSubmit', function () {
				if(dijit.byId('UserCookie').checked == true){
					dojo.cookie('user.username',dojo.byId('UserUsername').value);
					dojo.cookie('user.password',dojo.byId('UserPassword').value);
					dojo.cookie('user.cookie','true');
				}else{
					dojo.cookie('user.username',null);
					dojo.cookie('user.password',null);
					dojo.cookie('user.cookie',null);
				}
			});
		});
		if(dojo.cookie('user.username')) dojo.byId('UserUsername').value = dojo.cookie('user.username');
		if(dojo.cookie('user.password')) dojo.byId('UserPassword').value = dojo.cookie('user.password');
		if(dojo.cookie('user.cookie')) dijit.byId('UserCookie').checked = true;
	}
};